home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2001 October / macformat-108.iso / Shareware / Math scientific / PsyScript / libraries / stairCase.lib / stairCase.lib.rsrc / TEXT_1128.txt < prev    next >
Encoding:
Text File  |  2001-05-14  |  2.3 KB  |  64 lines

  1. date = 15/5/01
  2. changed parameters to pParameters
  3.  
  4. date = 19/4/2001
  5. ensured that duration does not go negative
  6.  
  7. added property pMyName : ""
  8.  
  9. added
  10.  
  11. added on getParametersAsSpreadsheetText(labelText)
  12.     return {{labelText & " maxreversals", maxreversals of parameters}, ¬¨
  13.         {labelText & " maxtrials", maxtrials of parameters}, ¬¨
  14.         {labelText & " stepSize", stepSize of parameters}, ¬¨
  15.         {labelText & " initialDuration", initialDuration of parameters}}
  16. end getParametersAsSpreadsheetText
  17.  
  18. Scoll down for a worked example
  19. --    usage: 
  20.         --1. Create a staircase with starting parameters
  21.                 set yourStairCaseName to load script file ("" & Psyscript base folder & "libraries:stairCase library")
  22.                          tell yourStairCaseName to initialize({maxreversals:10, maxtrials:20, stepSize:4, initialDuration:40})
  23.         --2. Start your trial loop
  24.                  Update the staircase after each trial
  25.                     update(gradedResponse) --0 for wrong, 1 for correct
  26.                 As necessary, update the stepSize
  27.                     updateStepSize(newStep)
  28.          3. Get data with:
  29.                 getRecord()
  30.                     -->stairCaseRecord
  31.                 getParameters()
  32.                      -->parameters
  33.                 completed()
  34.                     -->true/false
  35.         
  36.         --nb: handlers that begin with "i" are for internal use of the object
  37.         --you should not be calling them
  38.  
  39. EXAMPLE
  40. tell application "PsyScript"
  41.     activate
  42.     begin experiment
  43.     set startingParameters to {maxreversals:10, maxtrials:20, stepSize:4, initialDuration:40}
  44.       set myStairCase to load script file ("" & Psyscript base folder & "libraries:stairCase library")
  45.       tell myStairCase to initialize(startingParameters)
  46.     set myStairCase to my createStairCase(startingParameters)
  47.     set goodResponse to "Z"
  48.     set completed to false
  49.     set myDuration to initialDuration of startingParameters
  50.     repeat while not completed
  51.         do trial "!e  + #100 !e 'duration  = ?1 screen refreshes' !v?1 'Push ‚Äôz‚Äò to get this correct, any other to get it wrong'  !t(2000)" given {myDuration}
  52.         if (subject response = goodResponse) then
  53.             set gradedResponse to 1
  54.         else
  55.             set gradedResponse to 0
  56.         end if
  57.         set myDuration to update(gradedResponse) of myStairCase
  58.         set completed to completed() of myStairCase
  59.     end repeat
  60.     display dialog "that took" & trialCount of getRecord() of myStairCase
  61.     end experiment
  62. end tell
  63. return {getRecord() of myStairCase, getParameters() of myStairCase}
  64.